<script setup>
import { computed, ref } from 'vue';

const firstName = ref('科比')
const lastName = ref('布莱恩特')

const fullName = computed({
  get() {
    return firstName.value + '·' + lastName.value
  },
  set(newValue) {
    // console.log(newValue)
    firstName.value = newValue.split('·')[0]
    lastName.value = newValue.split('·')[1]
  }
})


</script>

<template>
  <div>
    <p>姓名: {{ fullName }}</p>
    <button @click="fullName = '勒布朗·詹姆斯'">改名</button>
  </div>
</template>

<style scoped></style>
